package com.xsky.logic.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.xsky.common.util.Sort;

public class Test
{
	/*public void advice(List sourceList, List flagList, List currList)
	{
		boolean flag = true;
		boolean curFlag = true;
		for(int i = 0; i < currList.size(); i++)
		{
			if((Integer)flagList.get(i)!=(Integer)currList.get(i)+1)
			{
				curFlag = false;
			}
			if((Integer)(currList.get(i))>0)
			{
				flag = false;
			}
		}
		if(curFlag)
		{
			
		}
		else
		{
			if(flag)
			{
				for(int i = 0; i < sourceList.size(); i++)
				{
					System.out.print(((List)(sourceList.get(i))).get((Integer)(currList.get(i))));
				}
				System.out.println();
				currList = genCurrList( flagList, currList);
				advice(sourceList, flagList, currList);
			}
			else
			{
				currList = genCurrList( flagList, currList);
				for(int i = 0; i < sourceList.size(); i++)
				{
					System.out.print(((List)(sourceList.get(i))).get((Integer)(currList.get(i))));
				}
				System.out.println();
				advice(sourceList, flagList, currList);
			}
		}
	}
	public List genCurrList(List flagList, List currList)
	{
		int[] arr = new int[currList.size()];
		for(int i = 0; i < arr.length; i++)
		{
			arr[i]=(Integer)currList.get(i);
		}
		for(int i=flagList.size()-1; i >=0; i--)//计算到第几位
		{
			int currInt = (Integer)currList.get(i)+1;
			int flagInt = (Integer)flagList.get(i);
			if(currInt<flagInt)
			{
				if(i==flagList.size()-1)
				{
					arr[i]=(Integer)currList.get(i)+1;
				}
				else
				{
					arr[i]=(Integer)currList.get(i)+1;
					for(int j = i+1; j < flagList.size();j++)
					{
						arr[j]=0;
					}
				}
				break;
			}
			else
			{
				
			}
		}
		List resultList = new ArrayList();
		for(int i = 0; i < arr.length; i++)
		{
			resultList.add(arr[i]);
		}
		return resultList;
	}
	public static void main(String[] args)
	{
		List list = new ArrayList();
		List strList1 = new ArrayList();
		strList1.add("a");
		strList1.add("b");
		strList1.add("c");
		strList1.add("d");
		List strList2 = new ArrayList();
		strList2.add("e");
		strList2.add("f");
		List strList3 = new ArrayList();
		strList3.add("g");
		strList3.add("h");
		strList3.add("i");
		List strList4 = new ArrayList();
		strList4.add("j");
		strList4.add("k");
		strList4.add("l");
		strList4.add("m");
		strList4.add("n");
		List sourceList = new ArrayList();
		sourceList.add(strList1);
		sourceList.add(strList2);
		sourceList.add(strList3);
		sourceList.add(strList4);
		List flagList = new ArrayList();
		flagList.add(strList1.size());
		flagList.add(strList2.size());
		flagList.add(strList3.size());
		flagList.add(strList4.size());
		List currList = new ArrayList();
		currList.add(0);
		currList.add(0);
		currList.add(0);
		currList.add(0);
		Test test = new Test();
		test.advice(sourceList, flagList, currList);
	}*/
	public List suoList(List list)
	{
		Random random = new Random();
		Sort sort = new Sort();
		int[] remove = new int[list.size()/2];
		for(int i = 0; i < list.size()/2; i++)
		{
			remove[i] = Math.abs(random.nextInt())%list.size();
		}
		remove = sort.paopao(remove);
		int last = 0;
		for(int i = 0; i < remove.length; i++)
		{
			if(last==0&&i!=0)
			{
				break;
			}
			if(last==remove[i])
			{
				last = remove[i]-1;
			}
			else
			{
				last = remove[i];
			}
			System.out.println(last);
			list.remove(last);
		}
		return list;
	}
	public static void main(String[] args)
	{
		Random random = new Random();
		List list = new ArrayList();
		list.add("a");
		list.add("b");
		list.add("c");
		list.add("d");
		list.add("e");
		list.add("f");
		list.add("g");
		list.add("h");
		list.add("i");
		Sort sort = new Sort();
		int[] remove = new int[list.size()/2];
		for(int i = 0; i < list.size()/2; i++)
		{
			remove[i] = Math.abs(random.nextInt())%list.size();
		}
		remove = sort.paopao(remove);
		int last = 0;
		for(int i = 0; i < remove.length; i++)
		{
			if(last==0&&i!=0)
			{
				break;
			}
			if(last==remove[i])
			{
				last = remove[i]-1;
			}
			else
			{
				last = remove[i];
			}
			System.out.println(last);
			list.remove(last);
		}
		for(int i = 0; i < list.size(); i++)
		{
			System.out.print(list.get(i));
		}
	}
}
